package com.example.normal.controller;

import cn.hutool.poi.excel.ExcelUtil;
import com.example.base.domain.PageVo;
import com.example.base.domain.TableDataInfo;
import com.example.base.result.AjaxResult;
import com.example.normal.entity.ClassInfo;
import com.example.normal.service.IClassInfoService;
import lombok.extern.java.Log;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

import javax.servlet.http.HttpServletResponse;
import java.util.List;

import static com.example.base.result.AjaxResult.success;

/**
 * 班级信息Controller
 *
 * @author wanghongyu02
 * @date 2024-08-14
 */
@RestController
@RequestMapping("/classInfo")
public class ClassInfoController {
    @Autowired
    private IClassInfoService classInfoService;

    /**
     * 查询班级信息列表
     */
    @GetMapping("/list")
    public AjaxResult list(@RequestBody ClassInfo classInfo, PageVo pageVo) {
        List<ClassInfo> list = classInfoService.selectClassInfoList(classInfo, pageVo);
        return success(list);
    }

    /**
     * 获取班级信息详细信息
     */
    @GetMapping(value = "/{classId}")
    public AjaxResult getInfo(@PathVariable("classId") Long classId) {
        return success(classInfoService.selectClassInfoByClassId(classId));
    }

    /**
     * 新增班级信息
     */
    @PostMapping
    public AjaxResult add(@RequestBody ClassInfo classInfo) {
        return success(classInfoService.insertClassInfo(classInfo));
    }

    /**
     * 修改班级信息
     */
    @PutMapping
    public AjaxResult edit(@RequestBody ClassInfo classInfo) {
        return success(classInfoService.updateClassInfo(classInfo));
    }

    /**
     * 删除班级信息
     */
    @DeleteMapping("/{classIds}")
    public AjaxResult remove(@PathVariable Long[] classIds) {
        return success(classInfoService.deleteClassInfoByClassIds(classIds));
    }
}